function className_delete(a){
    if(a==1){
        document.getElementById("admin_information1").className="";
        document.getElementById("admin_information2").className="";
    }
    else if(a==2){
        document.getElementById("admin_information").className="";
        document.getElementById("admin_information2").className="";
    }
    else{
        document.getElementById("admin_information").className="";
        document.getElementById("admin_information1").className="";
    }
}

function style_change(){
    document.getElementById("div1_select").style.display="none";
    document.getElementById("div2_select").style.display="none";
    document.getElementById("div3_select").style.display="none";
    document.getElementById("div4_select").style.display="none";
    document.getElementById("div1_select").innerHTML="";
    document.getElementById("div2_select").innerHTML="";
    document.getElementById("div3_select").innerHTML="";
    document.getElementById("div4_select").innerHTML="";
}
function admin_information_click(){
    style_change();
    document.getElementById("div1").style.display="block";
    document.getElementById("div2").style.display="none";
    document.getElementById("div3").style.display="none";
    document.getElementById("div4").style.display="none";
    document.getElementById("article_top1").style.display="block";
    document.getElementById("article_top2").style.display="none";
    document.getElementById("article_top3").style.display="none";
    document.getElementById("admin_information").className="active";
    document.getElementById("div4").innerHTML="";
    document.getElementById("div4").innerHTML="<input type=\"text\" id=\"buyer_search4\" placeholder=\"搜索商品ID或名称\">\n" +
        "           <input type=\"button\" id=\"buyer_search_button4\" value=\"搜索\" onclick=\"buyer_search_method4()\">";
    document.getElementById("div1").innerHTML="";
    document.getElementById("div1").innerHTML="<input type=\"text\" id=\"buyer_search\" placeholder=\"搜索用户ID或姓名\">\n" +
        "           <input type=\"button\" id=\"buyer_search_button\" value=\"搜索\" onclick=\"buyer_search_method()\">";
    className_delete(1)
    doLoad(per,0);
    dataTable.data(per,'userId');
}

function admin_information1_click(){
    style_change();
    document.getElementById("div1").style.display="none";
    document.getElementById("div2").style.display="block";
    document.getElementById("div3").style.display="none";
    document.getElementById("div4").style.display="none";
    document.getElementById("article_top1").style.display="none";
    document.getElementById("article_top2").style.display="block";
    document.getElementById("article_top3").style.display="none";
    document.getElementById("admin_information1").className="active";
    document.getElementById("div4").innerHTML="";
    document.getElementById("div4").innerHTML="<input type=\"text\" id=\"buyer_search4\" placeholder=\"搜索商品ID或名称\">\n" +
        "           <input type=\"button\" id=\"buyer_search_button4\" value=\"搜索\" onclick=\"buyer_search_method4()\">";
    document.getElementById("div2").innerHTML="";
    document.getElementById("div2").innerHTML="<input type=\"text\" id=\"buyer_search2\" placeholder=\"搜索店家ID或名称\">\n" +
        "        <input type=\"button\" id=\"buyer_search_button2\" value=\"搜索\" onclick=\"buyer_search_method2()\">";
    className_delete(2)
    doLoad(per2,0);
    dataTable.data(per2,'shopID');
}

function admin_information2_click() {
    style_change();
    document.getElementById("div1").style.display = "none";
    document.getElementById("div2").style.display = "none";
    document.getElementById("div3").style.display = "block";
    document.getElementById("div4").style.display="none";
    document.getElementById("article_top1").style.display="none";
    document.getElementById("article_top2").style.display="none";
    document.getElementById("article_top3").style.display="block";
    document.getElementById("admin_information2").className="active";
    document.getElementById("div4").innerHTML="";
    document.getElementById("div4").innerHTML="<input type=\"text\" id=\"buyer_search4\" placeholder=\"搜索商品ID或名称\">\n" +
        "           <input type=\"button\" id=\"buyer_search_button4\" value=\"搜索\" onclick=\"buyer_search_method4()\">";
    document.getElementById("div3").innerHTML="";
    document.getElementById("div3").innerHTML="<input type=\"text\" id=\"buyer_search3\" placeholder=\"搜索用户ID或姓名\">" +
        "<input type=\"button\" id=\"buyer_search_button3\" value=\"搜索\" onclick=\"buyer_search_method3()\">";
    className_delete(3)
    doLoad(per3,0);
    dataTable.data(per3,'userId');
}
var per = [
    {userId:120001,name:'张珊',birthday:'1952-02-23T12:10:38Z',sex:'男',phoneNumber:'13373275719',emailAddress:'1041455818@qq.com',id:'123456789123456789'},
    {userId:120002,name:'李四',birthday:'1952-02-23T12:10:38Z',sex:'男',phoneNumber:'13373275720',emailAddress:'1041455819@qq.com',id:'123456789123456790'},
    {userId:120001,name:'张珊',birthday:'1952-02-23T12:10:38Z',sex:'男',phoneNumber:'13373275719',emailAddress:'1041455818@qq.com',id:'123456789123456789'},
    {userId:120002,name:'李四',birthday:'1952-02-23T12:10:38Z',sex:'男',phoneNumber:'13373275720',emailAddress:'1041455819@qq.com',id:'123456789123456790'},
    {userId:120003,name:'王五',birthday:'1952-02-23T12:10:38Z',sex:'女',phoneNumber:'13373275729',emailAddress:'1041455823@qq.com',id:'123456789123456791'},
    {userId:120001,name:'张珊',birthday:'1952-02-23T12:10:38Z',sex:'男',phoneNumber:'13373275719',emailAddress:'1041455818@qq.com',id:'123456789123456789'},
    {userId:120002,name:'李四',birthday:'1952-02-23T12:10:38Z',sex:'男',phoneNumber:'13373275720',emailAddress:'1041455819@qq.com',id:'123456789123456790'},
    {userId:120001,name:'张珊',birthday:'1952-02-23T12:10:38Z',sex:'男',phoneNumber:'13373275719',emailAddress:'1041455818@qq.com',id:'123456789123456789'},
    {userId:120002,name:'李四',birthday:'1952-02-23T12:10:38Z',sex:'男',phoneNumber:'13373275720',emailAddress:'1041455819@qq.com',id:'123456789123456790'},
    {userId:120003,name:'王五',birthday:'1952-02-23T12:10:38Z',sex:'女',phoneNumber:'13373275729',emailAddress:'1041455823@qq.com',id:'123456789123456791'},
    {userId:120001,name:'张珊',birthday:'1952-02-23T12:10:38Z',sex:'男',phoneNumber:'13373275719',emailAddress:'1041455818@qq.com',id:'123456789123456789'},
    {userId:120002,name:'李四',birthday:'1952-02-23T12:10:38Z',sex:'男',phoneNumber:'13373275720',emailAddress:'1041455819@qq.com',id:'123456789123456790'},
    {userId:120001,name:'张珊',birthday:'1952-02-23T12:10:38Z',sex:'男',phoneNumber:'13373275719',emailAddress:'1041455818@qq.com',id:'123456789123456789'},
    {userId:120002,name:'李四',birthday:'1952-02-23T12:10:38Z',sex:'男',phoneNumber:'13373275720',emailAddress:'1041455819@qq.com',id:'123456789123456790'},
    {userId:120003,name:'王五',birthday:'1952-02-23T12:10:38Z',sex:'女',phoneNumber:'13373275729',emailAddress:'1041455823@qq.com',id:'123456789123456791'}
];
var per2=[
    {shopId:12000112001,shopName:'新华书店',createTime:'1952-02-23T12:10:38Z',ownerId:12345678912,totalSell:150000,count:10000},
    {shopId:12000212002,shopName:'新朝书店',createTime:'1952-02-23T12:10:38Z',ownerId:12345678913,totalSell:160000,count:20000},
    {shopId:12000312003,shopName:'东风书店',createTime:'1952-02-23T12:10:38Z',ownerId:12345678914,totalSell:170000,count:30000},
    {shopId:12000112001,shopName:'新华书店',createTime:'1952-02-23T12:10:38Z',ownerId:12345678912,totalSell:150000,count:10000},
    {shopId:12000212002,shopName:'新朝书店',createTime:'1952-02-23T12:10:38Z',ownerId:12345678913,totalSell:160000,count:20000},
    {shopId:12000312003,shopName:'东风书店',createTime:'1952-02-23T12:10:38Z',ownerId:12345678914,totalSell:170000,count:30000},
    {shopId:12000112001,shopName:'新华书店',createTime:'1952-02-23T12:10:38Z',ownerId:12345678912,totalSell:150000,count:10000},
    {shopId:12000212002,shopName:'新朝书店',createTime:'1952-02-23T12:10:38Z',ownerId:12345678913,totalSell:160000,count:20000},
    {shopId:12000312003,shopName:'东风书店',createTime:'1952-02-23T12:10:38Z',ownerId:12345678914,totalSell:170000,count:30000},
    {shopId:12000112001,shopName:'新华书店',createTime:'1952-02-23T12:10:38Z',ownerId:12345678912,totalSell:150000,count:10000},
    {shopId:12000212002,shopName:'新朝书店',createTime:'1952-02-23T12:10:38Z',ownerId:12345678913,totalSell:160000,count:20000},
    {shopId:12000312003,shopName:'东风书店',createTime:'1952-02-23T12:10:38Z',ownerId:12345678914,totalSell:170000,count:30000},
    {shopId:12000112001,shopName:'新华书店',createTime:'1952-02-23T12:10:38Z',ownerId:12345678912,totalSell:150000,count:10000},
    {shopId:12000212002,shopName:'新朝书店',createTime:'1952-02-23T12:10:38Z',ownerId:12345678913,totalSell:160000,count:20000},
    {shopId:12000312003,shopName:'东风书店',createTime:'1952-02-23T12:10:38Z',ownerId:12345678914,totalSell:170000,count:30000},
    {shopId:12000112001,shopName:'新华书店',createTime:'1952-02-23T12:10:38Z',ownerId:12345678912,totalSell:150000,count:10000},
    {shopId:12000212002,shopName:'新朝书店',createTime:'1952-02-23T12:10:38Z',ownerId:12345678913,totalSell:160000,count:20000},
    {shopId:12000312003,shopName:'东风书店',createTime:'1952-02-23T12:10:38Z',ownerId:12345678914,totalSell:170000,count:30000}
];
var per3=[
    {userId:120001,userAccount:'13373275719',userPassword:'s111111',userName:'张珊',address:'燕大西校区',avatar:'avatar1',identity:555555,createDate:"2019年2月1日"},
    {userId:120002,userAccount:'13373275720',userPassword:'s222222',userName:'李四',address:'燕大西校区',avatar:'avatar2',identity:666666,createDate:"2019年2月1日"},
    {userId:120003,userAccount:'13373275729',userPassword:'s333333',userName:'王五',address:'燕大东校区',avatar:'avatar3',identity:777777,createDate:"2019年2月1日"},
    {userId:120001,userAccount:'13373275719',userPassword:'s111111',userName:'张珊',address:'燕大西校区',avatar:'avatar1',identity:555555,createDate:"2019年2月1日"},
    {userId:120002,userAccount:'13373275720',userPassword:'s222222',userName:'李四',address:'燕大西校区',avatar:'avatar2',identity:666666,createDate:"2019年2月1日"},
    {userId:120003,userAccount:'13373275729',userPassword:'s333333',userName:'王五',address:'燕大东校区',avatar:'avatar3',identity:777777,createDate:"2019年2月1日"},
    {userId:120001,userAccount:'13373275719',userPassword:'s111111',userName:'张珊',address:'燕大西校区',avatar:'avatar1',identity:555555,createDate:"2019年2月1日"},
    {userId:120002,userAccount:'13373275720',userPassword:'s222222',userName:'李四',address:'燕大西校区',avatar:'avatar2',identity:666666,createDate:"2019年2月1日"},
    {userId:120003,userAccount:'13373275729',userPassword:'s333333',userName:'王五',address:'燕大东校区',avatar:'avatar3',identity:777777,createDate:"2019年2月1日"},
    {userId:120001,userAccount:'13373275719',userPassword:'s111111',userName:'张珊',address:'燕大西校区',avatar:'avatar1',identity:555555,createDate:"2019年2月1日"},
    {userId:120002,userAccount:'13373275720',userPassword:'s222222',userName:'李四',address:'燕大西校区',avatar:'avatar2',identity:666666,createDate:"2019年2月1日"},
    {userId:120003,userAccount:'13373275729',userPassword:'s333333',userName:'王五',address:'燕大东校区',avatar:'avatar3',identity:777777,createDate:"2019年2月1日"},
    {userId:120001,userAccount:'13373275719',userPassword:'s111111',userName:'张珊',address:'燕大西校区',avatar:'avatar1',identity:555555,createDate:"2019年2月1日"},
    {userId:120002,userAccount:'13373275720',userPassword:'s222222',userName:'李四',address:'燕大西校区',avatar:'avatar2',identity:666666,createDate:"2019年2月1日"},
    {userId:120003,userAccount:'13373275729',userPassword:'s333333',userName:'王五',address:'燕大东校区',avatar:'avatar3',identity:777777,createDate:"2019年2月1日"},
    {userId:120001,userAccount:'13373275719',userPassword:'s111111',userName:'张珊',address:'燕大西校区',avatar:'avatar1',identity:555555,createDate:"2019年2月1日"},
    {userId:120002,userAccount:'13373275720',userPassword:'s222222',userName:'李四',address:'燕大西校区',avatar:'avatar2',identity:666666,createDate:"2019年2月1日"},
    {userId:120003,userAccount:'13373275729',userPassword:'s333333',userName:'王五',address:'燕大东校区',avatar:'avatar3',identity:777777,createDate:"2019年2月1日"}
];
var per4=[
    {goodsId:11111111111,bookId:44444444444,bookName:'三国',goodsImage:'123',goodsName:'三国演义',shopId:12000112001,shopName:'新华书店',remain:100,price:10.5,sell:10000},
    {goodsId:22222222222,bookId:55555555555,bookName:'水浒',goodsImage:'456',goodsName:'水浒转',shopId:12000112001,shopName:'新华书店',remain:200,price:20.5,sell:20000},
    {goodsId:33333333333,bookId:66666666666,bookName:'西游记',goodsImage:'789',goodsName:'西游记',shopId:12000112001,shopName:'新华书店',remain:300,price:30.5,sell:30000},
    {goodsId:11111111111,bookId:44444444444,bookName:'三国',goodsImage:'123',goodsName:'三国演义',shopId:12000112001,shopName:'新华书店',remain:100,price:10.5,sell:10000},
    {goodsId:22222222222,bookId:55555555555,bookName:'水浒',goodsImage:'456',goodsName:'水浒转',shopId:12000112001,shopName:'新华书店',remain:200,price:20.5,sell:20000},
    {goodsId:33333333333,bookId:66666666666,bookName:'西游记',goodsImage:'789',goodsName:'西游记',shopId:12000112001,shopName:'新华书店',remain:300,price:30.5,sell:30000},
    {goodsId:11111111111,bookId:44444444444,bookName:'三国',goodsImage:'123',goodsName:'三国演义',shopId:12000112001,shopName:'新华书店',remain:100,price:10.5,sell:10000},
    {goodsId:22222222222,bookId:55555555555,bookName:'水浒',goodsImage:'456',goodsName:'水浒转',shopId:12000112001,shopName:'新华书店',remain:200,price:20.5,sell:20000},
    {goodsId:33333333333,bookId:66666666666,bookName:'西游记',goodsImage:'789',goodsName:'西游记',shopId:12000112001,shopName:'新华书店',remain:300,price:30.5,sell:30000},
    {goodsId:11111111111,bookId:44444444444,bookName:'三国',goodsImage:'123',goodsName:'三国演义',shopId:12000112001,shopName:'新华书店',remain:100,price:10.5,sell:10000},
    {goodsId:22222222222,bookId:55555555555,bookName:'水浒',goodsImage:'456',goodsName:'水浒转',shopId:12000112001,shopName:'新华书店',remain:200,price:20.5,sell:20000},
    {goodsId:33333333333,bookId:66666666666,bookName:'西游记',goodsImage:'789',goodsName:'西游记',shopId:12000112001,shopName:'新华书店',remain:300,price:30.5,sell:30000},
    {goodsId:11111111111,bookId:44444444444,bookName:'三国',goodsImage:'123',goodsName:'三国演义',shopId:12000112001,shopName:'新华书店',remain:100,price:10.5,sell:10000},
    {goodsId:22222222222,bookId:55555555555,bookName:'水浒',goodsImage:'456',goodsName:'水浒转',shopId:12000112001,shopName:'新华书店',remain:200,price:20.5,sell:20000},
    {goodsId:33333333333,bookId:66666666666,bookName:'西游记',goodsImage:'789',goodsName:'西游记',shopId:12000112001,shopName:'新华书店',remain:300,price:30.5,sell:30000},
    {goodsId:11111111111,bookId:44444444444,bookName:'三国',goodsImage:'123',goodsName:'三国演义',shopId:12000112001,shopName:'新华书店',remain:100,price:10.5,sell:10000},
    {goodsId:22222222222,bookId:55555555555,bookName:'水浒',goodsImage:'456',goodsName:'水浒转',shopId:12000112001,shopName:'新华书店',remain:200,price:20.5,sell:20000},
    {goodsId:33333333333,bookId:66666666666,bookName:'西游记',goodsImage:'789',goodsName:'西游记',shopId:12000112001,shopName:'新华书店',remain:300,price:30.5,sell:30000}
];
window.onload = function(){
    doLoad(per,0);
    dataTable.data(per,'userId');
    //doLoad(per2,0);
    //dataTable.data(per2,'shopID');
   // doLoad(per3,0);
   // dataTable.data(per3,'userId');
};

function buyer_search_method(){
    var  l=0;
    var m=0;
    var per_search_result1=[];
    for(var i = 0;i < per.length; i++){
        var userId=per[i].userId;
        var name=per[i].name;
        if(document.getElementById("buyer_search").value==userId){
            document.getElementById("div1").style.display="none";
            document.getElementById("div1_select").style.display="block";
            var per_search_result=
            [
               {userId:per[i].userId,name:per[i].name,birthday:per[i].birthday,sex:per[i].sex,phoneNumber:per[i].phoneNumber,emailAddress:per[i].emailAddress,id:per[i].id},
            ];
            doLoad(per,1);
            dataTable.data(per_search_result,'userId');
            l=1;
            break;
        }
        if(document.getElementById("buyer_search").value==name){
            document.getElementById("div1").style.display="none";
            document.getElementById("div1_select").style.display="block";
            per_search_result1.push(per[i]);
            l=1;
            m=1;
        }
    }
    if(m==1){
        doLoad(per,1);
        dataTable.data(per_search_result1,'userId');
    }
    if(l==0){
        alert("搜索结果不存在");
    }
}

function buyer_search_method2(){
    var  l=0;
    var m=0;
    var per_search_result1=[];
    for(var i = 0;i < per2.length; i++){
        var shopId=per2[i].shopId;
        var shopName=per2[i].shopName;
        if(document.getElementById("buyer_search2").value==shopId){
            document.getElementById("div2").style.display="none";
            document.getElementById("div2_select").style.display="block";
            doLoad(per2,1);
            var per_search_result=
                [
                    {shopId:per2[i].shopId,shopName:per2[i].shopName,createTime:per2[i].createTime,ownerId:per2[i].ownerId,totalSell:per2[i].totalSell,count:per2[i].count},
                ];
            dataTable.data(per_search_result,'shopId');
            l=1;
            break;
        }
        if(document.getElementById("buyer_search2").value==shopName){
            document.getElementById("div2").style.display="none";
            document.getElementById("div2_select").style.display="block";
            per_search_result1.push(per2[i]);
            l=1;
            m=1;
        }
    }
    if(m==1){
        doLoad(per2,1);
        dataTable.data(per_search_result1,'shopId');
    }
    if(l==0){
        alert("搜索结果不存在");
    }
}

function buyer_search_method3(){
    var  l=0;
    var m=0;
    var per_search_result1=[];
    for(var i = 0;i < per3.length; i++){
        var userId=per3[i].userId;
        var userName=per3[i].userName;
        if(document.getElementById("buyer_search3").value==userId){
            document.getElementById("div3").style.display="none";
            document.getElementById("div3_select").style.display="block";
            doLoad(per3,1);
            var per_search_result=
                [
                    {userId:per3[i].userId,userAccount:per3[i].userAccount,userPassword:per3[i].userPassword,userName:per3[i].userName,address:per3[i].address,avatar:per3[i].avatar,identity:per3[i].identity,createDate:per3[i].createDate},
                ]
            dataTable.data(per_search_result,'userId');
            l=1;
            break;
        }
        if(document.getElementById("buyer_search3").value==userName){
            document.getElementById("div3").style.display="none";
            document.getElementById("div3_select").style.display="block";
            per_search_result1.push(per3[i]);
            l=1;
            m=1;
        }
    }
    if(m==1){
        doLoad(per3,1);
        dataTable.data(per_search_result1,'userId');
    }
    if(l==0){
        alert("搜索结果不存在");
    }
}

function buyer_search_method4(){
    var  l=0;
    var m=0;
    var per_search_result1=[];
    for(var i = 0;i < per4.length; i++){
        var goodsId=per4[i].goodsId;
        var goodsName=per4[i].goodsName;
        if(document.getElementById("buyer_search4").value==goodsId){
            document.getElementById("div4").style.display="none";
            document.getElementById("div4_select").style.display="block";
            doLoad(per4,1);
            var per_search_result=
                [
                    {goodsId:per4[i].goodsId,bookId:per4[i].bookId,bookName:per4[i].bookName,goodsImage:per4[i].goodsImage,goodsName:per4[i].goodsName,shopId:per4[i].shopId,shopName:per4[i].shopName,remain:per4[i].remain,price:per4[i].price,sell:per4[i].sell},
                ]
            dataTable.data(per_search_result,'goodsId');
            l=1;
            break;
        }
        if(document.getElementById("buyer_search4").value==goodsName){
            document.getElementById("div4").style.display="none";
            document.getElementById("div4_select").style.display="block";
            per_search_result1.push(per4[i]);
            l=1;
            m=1;
        }
    }
    if(m==1){
        doLoad(per4,1);
        dataTable.data(per_search_result1,'goodsId');
    }
    if(l==0){
        alert("搜索结果不存在");
    }
}
